 /* Copyright 2018 JDCLOUD.COM

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http:#www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

JCLOUD IoT Engine API
API related to IoT Engine

OpenAPI spec version: v2
Contact: 

NOTE: This class is auto generated by the jdcloud code generator program.
*/


#import <Foundation/Foundation.h>
#import <JDCloudOCSDKIotcore/IotcoreExecutor.h>

@implementation IotcoreClient

@synthesize userAgent = _userAgent;
@synthesize serviceName = _serviceName;
@synthesize version = _version;

-(void) addCustomerHeaderWithKey:(NSString*) key
                           value:(NSString*) value{
    if(![self customHeader])
    {
        self.customHeader = [[NSMutableDictionary alloc] init];
    }
    if(key && value)
    {
        [[self customHeader] setValue:value forKey:key];
    }
   
}

-(id)initWithGlobalConfig{
    if(![GlobalConfig credential])
    {
        NSException *e = [SDKArgumentNullException exceptionWithName:@"ArgumentNullException" reason:@"GlobalConfig credential not config" userInfo:nil];
        @throw e;
    }
    self.credential = [GlobalConfig credential];
    if(![GlobalConfig sdkEnvironment])
    {
        self.sdkEnvironment = [[SDKEnvironment alloc] initWithEndPoint:@"iotcore.jdcloud-api.com"];
    }else
    {
        self.sdkEnvironment = [GlobalConfig sdkEnvironment];
    }
    self.httpRequestProtocol = @"https";
    _userAgent = @"JdCloudOCSdk 0.0.1 iotcore  v2";
    _serviceName = @"iotcore";
    _version = @"v2";
    self.contentType = @"application/json";
    return self;
}

-(id)initWithCredential:(Credential*)credential
         sdkEnvironment:(SDKEnvironment*)sdkEnvironment
{
    if(!credential)
    {
        NSException *e = [SDKArgumentNullException exceptionWithName:@"ArgumentNullException" reason:@" credential can not null" userInfo:nil];
        @throw e;
    }else{
        self.credential = credential;
    }
    
    if(!sdkEnvironment)
    {
        NSException *e = [SDKArgumentNullException exceptionWithName:@"ArgumentNullException" reason:@" sdkEnvironment can not null" userInfo:nil];
        @throw e;
    }else{
        self.sdkEnvironment = sdkEnvironment;
    }
    self.httpRequestProtocol = @"https";
    _userAgent = @"JdCloudOCSdk 0.0.1 iotcore  v2";
    _serviceName = @"iotcore";
    _version = @"v2";
    self.contentType = @"application/json";
    return self;
}

-(id)initWithCredential:(Credential*)credential
{
    if(!credential)
    {
        NSException *e = [SDKArgumentNullException exceptionWithName:@"ArgumentNullException" reason:@" credential can not null" userInfo:nil];
        @throw e;
    }else{
        self.credential = credential;
    }
    if(![GlobalConfig sdkEnvironment])
    {
        self.sdkEnvironment = [[SDKEnvironment alloc] initWithEndPoint:@"iotcore.jdcloud-api.com"];
    }else
    {
        self.sdkEnvironment = [GlobalConfig sdkEnvironment];
    }
    self.httpRequestProtocol = @"https";
    _userAgent = @"JdCloudOCSdk 0.0.1 iotcore  v2";
    _serviceName = @"iotcore";
    _version = @"v2";
    self.contentType = @"application/json";
    return self;
}

-(id)init{
    self.httpRequestProtocol = @"https";
    _userAgent = @"JdCloudOCSdk 0.0.1 iotcore  v2";
    _serviceName = @"iotcore";
    _version = @"v2";
    self.contentType = @"application/json";
    return self;
}


/**
addDevice sync request
@param addDeviceRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `addDeviceResponse` the request response data model
*/
-(NSDictionary*) addDeviceSyncWithRequest:(IotcoreAddDeviceRequest*) addDeviceRequest
{
IotcoreAddDeviceExecutor* excutor = [[IotcoreAddDeviceExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:addDeviceRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreAddDeviceResponse* response = [[IotcoreAddDeviceResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"addDeviceResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)addDeviceAsyncWithRequest:(IotcoreAddDeviceRequest*) addDeviceRequest
                       completionHandler:(void(^)(int statusCode,IotcoreAddDeviceResponse* _Nullable addDeviceResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreAddDeviceExecutor* excutor = [[IotcoreAddDeviceExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:addDeviceRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreAddDeviceResponse* response = [[IotcoreAddDeviceResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
createProductTopic sync request
@param createProductTopicRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `createProductTopicResponse` the request response data model
*/
-(NSDictionary*) createProductTopicSyncWithRequest:(IotcoreCreateProductTopicRequest*) createProductTopicRequest
{
IotcoreCreateProductTopicExecutor* excutor = [[IotcoreCreateProductTopicExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:createProductTopicRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreCreateProductTopicResponse* response = [[IotcoreCreateProductTopicResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"createProductTopicResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)createProductTopicAsyncWithRequest:(IotcoreCreateProductTopicRequest*) createProductTopicRequest
                       completionHandler:(void(^)(int statusCode,IotcoreCreateProductTopicResponse* _Nullable createProductTopicResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreCreateProductTopicExecutor* excutor = [[IotcoreCreateProductTopicExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:createProductTopicRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreCreateProductTopicResponse* response = [[IotcoreCreateProductTopicResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
updateThingShadow sync request
@param updateThingShadowRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `updateThingShadowResponse` the request response data model
*/
-(NSDictionary*) updateThingShadowSyncWithRequest:(IotcoreUpdateThingShadowRequest*) updateThingShadowRequest
{
IotcoreUpdateThingShadowExecutor* excutor = [[IotcoreUpdateThingShadowExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:updateThingShadowRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreUpdateThingShadowResponse* response = [[IotcoreUpdateThingShadowResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"updateThingShadowResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)updateThingShadowAsyncWithRequest:(IotcoreUpdateThingShadowRequest*) updateThingShadowRequest
                       completionHandler:(void(^)(int statusCode,IotcoreUpdateThingShadowResponse* _Nullable updateThingShadowResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreUpdateThingShadowExecutor* excutor = [[IotcoreUpdateThingShadowExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:updateThingShadowRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreUpdateThingShadowResponse* response = [[IotcoreUpdateThingShadowResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
deleteProduct sync request
@param deleteProductRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `deleteProductResponse` the request response data model
*/
-(NSDictionary*) deleteProductSyncWithRequest:(IotcoreDeleteProductRequest*) deleteProductRequest
{
IotcoreDeleteProductExecutor* excutor = [[IotcoreDeleteProductExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:deleteProductRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreDeleteProductResponse* response = [[IotcoreDeleteProductResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"deleteProductResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)deleteProductAsyncWithRequest:(IotcoreDeleteProductRequest*) deleteProductRequest
                       completionHandler:(void(^)(int statusCode,IotcoreDeleteProductResponse* _Nullable deleteProductResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreDeleteProductExecutor* excutor = [[IotcoreDeleteProductExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:deleteProductRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreDeleteProductResponse* response = [[IotcoreDeleteProductResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
queryDevicePage sync request
@param queryDevicePageRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `queryDevicePageResponse` the request response data model
*/
-(NSDictionary*) queryDevicePageSyncWithRequest:(IotcoreQueryDevicePageRequest*) queryDevicePageRequest
{
IotcoreQueryDevicePageExecutor* excutor = [[IotcoreQueryDevicePageExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:queryDevicePageRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreQueryDevicePageResponse* response = [[IotcoreQueryDevicePageResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"queryDevicePageResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)queryDevicePageAsyncWithRequest:(IotcoreQueryDevicePageRequest*) queryDevicePageRequest
                       completionHandler:(void(^)(int statusCode,IotcoreQueryDevicePageResponse* _Nullable queryDevicePageResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreQueryDevicePageExecutor* excutor = [[IotcoreQueryDevicePageExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:queryDevicePageRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreQueryDevicePageResponse* response = [[IotcoreQueryDevicePageResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
invokeThingService sync request
@param invokeThingServiceRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `invokeThingServiceResponse` the request response data model
*/
-(NSDictionary*) invokeThingServiceSyncWithRequest:(IotcoreInvokeThingServiceRequest*) invokeThingServiceRequest
{
IotcoreInvokeThingServiceExecutor* excutor = [[IotcoreInvokeThingServiceExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:invokeThingServiceRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreInvokeThingServiceResponse* response = [[IotcoreInvokeThingServiceResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"invokeThingServiceResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)invokeThingServiceAsyncWithRequest:(IotcoreInvokeThingServiceRequest*) invokeThingServiceRequest
                       completionHandler:(void(^)(int statusCode,IotcoreInvokeThingServiceResponse* _Nullable invokeThingServiceResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreInvokeThingServiceExecutor* excutor = [[IotcoreInvokeThingServiceExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:invokeThingServiceRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreInvokeThingServiceResponse* response = [[IotcoreInvokeThingServiceResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
describeThingShadow sync request
@param describeThingShadowRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `describeThingShadowResponse` the request response data model
*/
-(NSDictionary*) describeThingShadowSyncWithRequest:(IotcoreDescribeThingShadowRequest*) describeThingShadowRequest
{
IotcoreDescribeThingShadowExecutor* excutor = [[IotcoreDescribeThingShadowExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:describeThingShadowRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreDescribeThingShadowResponse* response = [[IotcoreDescribeThingShadowResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"describeThingShadowResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)describeThingShadowAsyncWithRequest:(IotcoreDescribeThingShadowRequest*) describeThingShadowRequest
                       completionHandler:(void(^)(int statusCode,IotcoreDescribeThingShadowResponse* _Nullable describeThingShadowResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreDescribeThingShadowExecutor* excutor = [[IotcoreDescribeThingShadowExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:describeThingShadowRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreDescribeThingShadowResponse* response = [[IotcoreDescribeThingShadowResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
invokeThingTopic sync request
@param invokeThingTopicRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `invokeThingTopicResponse` the request response data model
*/
-(NSDictionary*) invokeThingTopicSyncWithRequest:(IotcoreInvokeThingTopicRequest*) invokeThingTopicRequest
{
IotcoreInvokeThingTopicExecutor* excutor = [[IotcoreInvokeThingTopicExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:invokeThingTopicRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreInvokeThingTopicResponse* response = [[IotcoreInvokeThingTopicResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"invokeThingTopicResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)invokeThingTopicAsyncWithRequest:(IotcoreInvokeThingTopicRequest*) invokeThingTopicRequest
                       completionHandler:(void(^)(int statusCode,IotcoreInvokeThingTopicResponse* _Nullable invokeThingTopicResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreInvokeThingTopicExecutor* excutor = [[IotcoreInvokeThingTopicExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:invokeThingTopicRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreInvokeThingTopicResponse* response = [[IotcoreInvokeThingTopicResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
listProducts sync request
@param listProductsRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `listProductsResponse` the request response data model
*/
-(NSDictionary*) listProductsSyncWithRequest:(IotcoreListProductsRequest*) listProductsRequest
{
IotcoreListProductsExecutor* excutor = [[IotcoreListProductsExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:listProductsRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreListProductsResponse* response = [[IotcoreListProductsResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"listProductsResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)listProductsAsyncWithRequest:(IotcoreListProductsRequest*) listProductsRequest
                       completionHandler:(void(^)(int statusCode,IotcoreListProductsResponse* _Nullable listProductsResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreListProductsExecutor* excutor = [[IotcoreListProductsExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:listProductsRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreListProductsResponse* response = [[IotcoreListProductsResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
createProduct sync request
@param createProductRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `createProductResponse` the request response data model
*/
-(NSDictionary*) createProductSyncWithRequest:(IotcoreCreateProductRequest*) createProductRequest
{
IotcoreCreateProductExecutor* excutor = [[IotcoreCreateProductExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:createProductRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreCreateProductResponse* response = [[IotcoreCreateProductResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"createProductResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)createProductAsyncWithRequest:(IotcoreCreateProductRequest*) createProductRequest
                       completionHandler:(void(^)(int statusCode,IotcoreCreateProductResponse* _Nullable createProductResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreCreateProductExecutor* excutor = [[IotcoreCreateProductExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:createProductRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreCreateProductResponse* response = [[IotcoreCreateProductResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
exportThingModel sync request
@param exportThingModelRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `exportThingModelResponse` the request response data model
*/
-(NSDictionary*) exportThingModelSyncWithRequest:(IotcoreExportThingModelRequest*) exportThingModelRequest
{
IotcoreExportThingModelExecutor* excutor = [[IotcoreExportThingModelExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:exportThingModelRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreExportThingModelResponse* response = [[IotcoreExportThingModelResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"exportThingModelResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)exportThingModelAsyncWithRequest:(IotcoreExportThingModelRequest*) exportThingModelRequest
                       completionHandler:(void(^)(int statusCode,IotcoreExportThingModelResponse* _Nullable exportThingModelResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreExportThingModelExecutor* excutor = [[IotcoreExportThingModelExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:exportThingModelRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreExportThingModelResponse* response = [[IotcoreExportThingModelResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
listProductAbilities sync request
@param listProductAbilitiesRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `listProductAbilitiesResponse` the request response data model
*/
-(NSDictionary*) listProductAbilitiesSyncWithRequest:(IotcoreListProductAbilitiesRequest*) listProductAbilitiesRequest
{
IotcoreListProductAbilitiesExecutor* excutor = [[IotcoreListProductAbilitiesExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:listProductAbilitiesRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreListProductAbilitiesResponse* response = [[IotcoreListProductAbilitiesResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"listProductAbilitiesResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)listProductAbilitiesAsyncWithRequest:(IotcoreListProductAbilitiesRequest*) listProductAbilitiesRequest
                       completionHandler:(void(^)(int statusCode,IotcoreListProductAbilitiesResponse* _Nullable listProductAbilitiesResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreListProductAbilitiesExecutor* excutor = [[IotcoreListProductAbilitiesExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:listProductAbilitiesRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreListProductAbilitiesResponse* response = [[IotcoreListProductAbilitiesResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
describeProduct sync request
@param describeProductRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `describeProductResponse` the request response data model
*/
-(NSDictionary*) describeProductSyncWithRequest:(IotcoreDescribeProductRequest*) describeProductRequest
{
IotcoreDescribeProductExecutor* excutor = [[IotcoreDescribeProductExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:describeProductRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreDescribeProductResponse* response = [[IotcoreDescribeProductResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"describeProductResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)describeProductAsyncWithRequest:(IotcoreDescribeProductRequest*) describeProductRequest
                       completionHandler:(void(^)(int statusCode,IotcoreDescribeProductResponse* _Nullable describeProductResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreDescribeProductExecutor* excutor = [[IotcoreDescribeProductExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:describeProductRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreDescribeProductResponse* response = [[IotcoreDescribeProductResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
updateDevice sync request
@param updateDeviceRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `updateDeviceResponse` the request response data model
*/
-(NSDictionary*) updateDeviceSyncWithRequest:(IotcoreUpdateDeviceRequest*) updateDeviceRequest
{
IotcoreUpdateDeviceExecutor* excutor = [[IotcoreUpdateDeviceExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:updateDeviceRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreUpdateDeviceResponse* response = [[IotcoreUpdateDeviceResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"updateDeviceResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)updateDeviceAsyncWithRequest:(IotcoreUpdateDeviceRequest*) updateDeviceRequest
                       completionHandler:(void(^)(int statusCode,IotcoreUpdateDeviceResponse* _Nullable updateDeviceResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreUpdateDeviceExecutor* excutor = [[IotcoreUpdateDeviceExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:updateDeviceRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreUpdateDeviceResponse* response = [[IotcoreUpdateDeviceResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
updateProduct sync request
@param updateProductRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `updateProductResponse` the request response data model
*/
-(NSDictionary*) updateProductSyncWithRequest:(IotcoreUpdateProductRequest*) updateProductRequest
{
IotcoreUpdateProductExecutor* excutor = [[IotcoreUpdateProductExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:updateProductRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreUpdateProductResponse* response = [[IotcoreUpdateProductResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"updateProductResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)updateProductAsyncWithRequest:(IotcoreUpdateProductRequest*) updateProductRequest
                       completionHandler:(void(^)(int statusCode,IotcoreUpdateProductResponse* _Nullable updateProductResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreUpdateProductExecutor* excutor = [[IotcoreUpdateProductExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:updateProductRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreUpdateProductResponse* response = [[IotcoreUpdateProductResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
queryDeviceDetail sync request
@param queryDeviceDetailRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `queryDeviceDetailResponse` the request response data model
*/
-(NSDictionary*) queryDeviceDetailSyncWithRequest:(IotcoreQueryDeviceDetailRequest*) queryDeviceDetailRequest
{
IotcoreQueryDeviceDetailExecutor* excutor = [[IotcoreQueryDeviceDetailExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:queryDeviceDetailRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreQueryDeviceDetailResponse* response = [[IotcoreQueryDeviceDetailResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"queryDeviceDetailResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)queryDeviceDetailAsyncWithRequest:(IotcoreQueryDeviceDetailRequest*) queryDeviceDetailRequest
                       completionHandler:(void(^)(int statusCode,IotcoreQueryDeviceDetailResponse* _Nullable queryDeviceDetailResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreQueryDeviceDetailExecutor* excutor = [[IotcoreQueryDeviceDetailExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:queryDeviceDetailRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreQueryDeviceDetailResponse* response = [[IotcoreQueryDeviceDetailResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
importThingModel sync request
@param importThingModelRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `importThingModelResponse` the request response data model
*/
-(NSDictionary*) importThingModelSyncWithRequest:(IotcoreImportThingModelRequest*) importThingModelRequest
{
IotcoreImportThingModelExecutor* excutor = [[IotcoreImportThingModelExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:importThingModelRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreImportThingModelResponse* response = [[IotcoreImportThingModelResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"importThingModelResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)importThingModelAsyncWithRequest:(IotcoreImportThingModelRequest*) importThingModelRequest
                       completionHandler:(void(^)(int statusCode,IotcoreImportThingModelResponse* _Nullable importThingModelResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreImportThingModelExecutor* excutor = [[IotcoreImportThingModelExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:importThingModelRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreImportThingModelResponse* response = [[IotcoreImportThingModelResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
removeDevice sync request
@param removeDeviceRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `removeDeviceResponse` the request response data model
*/
-(NSDictionary*) removeDeviceSyncWithRequest:(IotcoreRemoveDeviceRequest*) removeDeviceRequest
{
IotcoreRemoveDeviceExecutor* excutor = [[IotcoreRemoveDeviceExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:removeDeviceRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreRemoveDeviceResponse* response = [[IotcoreRemoveDeviceResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"removeDeviceResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)removeDeviceAsyncWithRequest:(IotcoreRemoveDeviceRequest*) removeDeviceRequest
                       completionHandler:(void(^)(int statusCode,IotcoreRemoveDeviceResponse* _Nullable removeDeviceResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
IotcoreRemoveDeviceExecutor* excutor = [[IotcoreRemoveDeviceExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:removeDeviceRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    IotcoreRemoveDeviceResponse* response = [[IotcoreRemoveDeviceResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}


 /**
 iotcore common sync request
 @param  jdcloudDataRequest request param
 @return key `statusCode` http request status code type is int
             `dataResult` the http request response data  type is NSData
             `requestError` the request error type is NSError
 */
 -(NSDictionary*) iotcoreCommonSyncWithRequest:(JDCloudDataRequest*) jdcloudDataRequest
                                                   url:(NSString*) url
                                                method:(NSString*) method{
    CommonExecutor* excutor = [[CommonExecutor alloc] initWithJDCloudClient:self url:url method:method];
    NSDictionary* responseResult = [excutor executeDataSync:jdcloudDataRequest];
    return responseResult;
}

-(void)iotcoreCommonAsyncWithRequest:(JDCloudDataRequest*) jdcloudDataRequest
                                         url:(NSString*) url
                                      method:(NSString*) method
                           completionHandler:(void(^)(int statusCode, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
     CommonExecutor* excutor = [[CommonExecutor alloc] initWithJDCloudClient:self url:url method:method];
    
    [excutor executeDataAsync:jdcloudDataRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        completionHandler(statusCode,responseData,error);
    }];
} 

@end
